package org.springblade.modules.restaurant.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springblade.core.secure.utils.SecureUtil;
import org.springblade.core.tool.api.R;
import org.springblade.modules.restaurant.service.IPurchaseCategoryService;
import org.springblade.modules.restaurant.vo.PurchaseCategoryTreeVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 采购类别
 *
 * @author harry
 * @公众号 Harry技术
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/restaurant/purchase")
@Tag(name = "API - 采购类别")
public class ApiPurchaseController {

	private IPurchaseCategoryService purchaseCategoryService;

	@GetMapping("/tree")
	@ApiOperationSupport(order = 2)
	@Operation(summary = "采购类别")
	public R<List<PurchaseCategoryTreeVO>> tree(String commodityName) {
		// 获取当前登录用户ID
		Long userId = SecureUtil.getUserId();
		String tenantId = SecureUtil.getTenantId();
		return R.data(purchaseCategoryService.listPurchaseCategory(commodityName,userId,tenantId));
	}

}
